import cliente
import sys

if len(sys.argv) < 2:
    print "Uso: python cssendfile.py <host> <port> [outfile]"
    exit

try:
    host = sys.argv[1]
    port = int(sys.argv[2])

    c = cliente.Cliente()

    c.Conectar(host, port)

    if len(sys.argv) > 3:
        outfileparam = {"name" :sys.argv[3]}
        c.EnviarComandoSync("outfile?", outfileparam)

    for line in sys.stdin:
            c.EnviarDato(line)

    print "Fin de envio de datos"
except Exception as details:
    sys.stderr.write("[ERROR] %s\n" % str(details))
    sys.exit(2)

    
	
